package com.wx.jpa.config;

import org.hibernate.boot.model.naming.PhysicalNamingStrategy;
import org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

/**
 * @ClassName JdbcConfig
 * @Author wx
 * @Description 多数据源配置类
 * @Date 2018-12-26-21:55
 */
@Configuration
public class JdbcConfig {
    @Bean
    @Primary
    @Qualifier(value = "dataSourceOne")
    @ConfigurationProperties(prefix = "spring.datasource.dbone")
    public DataSource dataSourceOne(){
        return DataSourceBuilder.create().build();
    }

    @Bean
    @Qualifier(value = "dataSourceTwo")
    @ConfigurationProperties(prefix = "spring.datasource.dbtwo")
    public DataSource dataSourceTwo(){
        return DataSourceBuilder.create().build();
    }

}
